package com.cly.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.cly.base.entity.BaseEntity;
import com.cly.enums.FileCategoryEnum;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import java.io.Serial;

/**
 * 消息实体类
 *
 * @author by 春风能解释
 * <p>
 * 2025/1/22
 */
@EqualsAndHashCode(callSuper = true)
@Data
@Accessors(chain = true)
@NoArgsConstructor
@Schema(name = "消息实体类", description = "消息实体类")
public class Message extends BaseEntity {

    /**
     * 序列化id
     */
    @Serial
    private static final long serialVersionUID = 6650553248239732463L;

    /**
     * 消息频道id
     */
    @Schema(description = "通道id")
    private String channelId;

    /**
     * 消息类型
     */
    @Schema(description = "消息类型")
    private Integer type;
    /**
     * 发送者id
     */
    @Schema(description = "发送者id")
    @TableField("`from`")
    @JsonFormat(shape = JsonFormat.Shape.STRING)
    private Long from;

    /**
     * 接收者id
     */
    @Schema(description = "接收者id")
    @TableField("`to`")
    @JsonFormat(shape = JsonFormat.Shape.STRING)
    private Long to;

    /**
     * 群组id
     */
    @Schema(description = "群组id")
    @JsonFormat(shape = JsonFormat.Shape.STRING)
    private Long groupId;

    /**
     * 消息
     */
    @Schema(description = "消息体")
    private Object content;

    /**
     * 是否是文本消息
     */
    @Schema(description = "是否是文本消息")
    private Boolean isText = true;

    /**
     * 是否是群发
     */
    @Schema(description = "是否群发")
    private Boolean isGroup = false;

    /**
     * 消息体类型
     */
    @Schema(description = "消息体类型")
    private FileCategoryEnum bodyType = FileCategoryEnum.TEXT;

    @Override
    public String toString() {
        return super.toString();
    }
}
